//
//  HomeTableViewCell.m
//  HappyToday
//
//  Created by Ale (ziming) Lee on 16/8/8.
//  Copyright © 2016年 ziming_lee. All rights reserved.
//

#import "HomeTableViewCell.h"


@implementation HomeTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setHomeModel:(HomeModel *)homeModel{
    _homeModel = homeModel;
    self.title.text = _homeModel.title;
    self.timestr.text = _homeModel.timestr;

    /*属性文本*/
    NSString *venuename = _homeModel.venuename;
    NSString *pricestr = _homeModel.pricestr;
    NSLog(@"%@",pricestr);
    NSString *price = [Regex getRegexStringFrom:pricestr withRegularString:@".+-"];
    price = [price substringWithRange:NSMakeRange(0, price.length-1)];

    if (price.length == 0) {

        self.venuename.text = venuename;

    }else{

        NSMutableAttributedString *mAString = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@￥%@起",venuename,price]];
        NSLog(@"%@",mAString);
        NSInteger location = venuename.length;
        NSInteger lenth = price.length;
        [mAString addAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} range:NSMakeRange(location, lenth+2)];
        [mAString addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17.0]} range:NSMakeRange(location+1, lenth)];
        self.venuename.attributedText = mAString;
    }

    NSURL *picURL = [NSURL URLWithString:_homeModel.pic];
    [self.pic setImageWithURL:picURL];



}




@end
